<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<header th:replace="inc/header"></header>

<body th:with="menu='doctor'">
<nav th:replace="inc/nav"></nav>
<style>
	.treeview ul.list-group,.treeview0 ul.list-group{
		position:absolute;
		left: 80px;
    	top: -5px;
	}
	.treeview ul li.list-group-item,.treeview0 ul li.list-group-item{
		/* height:30px; */
		line-height:30px;
		padding: 0 15px;
		cursor:pointer;
	}
	.node-treeview2{
		display:none;
	} 
	.search-title .dropdown-menu .divider{
		margin:0;
	}
	.doctor-type ul li a,
	.isDone ul li a, 
	.isDisease ul li a{
		line-height:2;
	}
	.doctor-start-time,
	.doctor-end-time{
		width:150px;
	}
	.doctor-name{
		width:100px;
	}
	#doctor .col-md-2,
	#doctor .col-md-3{
		padding:0;
	}
	.btnHandle{
		margin-right:5px;
	}
	.doctorHandle{
		margin-right:5px;
	}
</style>
<div class="container-fluid doctorBox">
  <div class="row">
    <div th:replace="inc/sidebar"></div>
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
      <h1 class="page-header">
        个人医疗记录查询
      </h1>
      <div class=" col-md-12 search-title">
      	<div class="col-md-11">
      		<div class="col-md-2" style="display:none;">
      			<span class="font-weight">监所编号：</span><span class="doctor-jsbh" th:text="${jsbh}"></span>
      		</div>
      		
 			<div id="doctor" class="treeview  treeviewpublic col-md-2">
 				<span class="font-weight">类型：</span>
	 			<span>医生</span>
				
 			</div>
 			<div class="col-md-2">
 				<span class="font-weight">姓名：</span>
				<input class="doctor-name" type="text" />
 			</div>
<!--  			<div class="col-md-2">
 				<span class="font-weight">是否完成：</span>
				<div class="btn-group isDone">
				  <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
				    <span class="done-text">全部</span> <span class="caret"></span>
				  </button>
				  <ul class="dropdown-menu">
				    <li class="done-no done-list"><a href="#">全部</a></li>
				    <li role="separator" class="divider"></li>
				    <li class="done-yes done-list" done="true"><a href="#">已处理</a></li>
				    <li role="separator" class="divider"></li>
				    <li class="done-no done-list" done="false"><a href="#">未处理</a></li>
				  </ul>
				</div>
 			</div> -->
      		<div class="col-md-4">
      			<span class="font-weight">开始时间：</span><input type="text" name="datetime" class="ui_timepicker doctor-start-time" value="">
      		</div>
      		<div class="col-md-4">
      			<span class="font-weight">结束时间：</span><input type="text" name="datetime" class="ui_timepicker doctor-end-time" value="">
      		</div>
      	</div>
      
      	<div class="col-md-1">
          <a class="btn btn-primary btn-sm" id="doctorSearch">查询</a>
        </div>
      </div>
      <table class="table table-striped searchList doctorsearch">
        <thead>
        <tr>
          <th>姓名</th>
          <th>人员编号</th>
          <th>类型</th>
          <th>疾病</th>
          <!-- <th>是否完成</th> -->
          <th>是否处理</th>
          <th>开始时间</th>
          <th>结束时间</th>
          <th>操作</th>
        </tr>
        </thead>
        <tbody>
        	<!-- <tr><td>"+name+"</td><td>"+rybh+"</td><td>"+type+"</td><td>"+disease+"</td><td>"+done+"</td><td>"+startTime+"</td><td>"+endTime+"</td></tr> -->
        </tbody>
      </table>
    </div>
  </div>
  
  	<!-- Modal -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
	  <div class="modal-dialog" role="document" style="width: 300px;">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title" id="myModalLabel">提示</h4>
	      </div>
	      <div class="modal-body" style="font-size: 18px;text-align: center">
	        是否处理？
	      </div>
	      <div class="modal-footer">
	        <button type="button" class="btn btn-default doctorNo" data-dismiss="modal">取消</button>
	        <button type="button" class="btn btn-primary doctorSure" data-dismiss="modal">确定</button>
	      </div>
	    </div>
	  </div>
	</div>
	
		<div class="modal fade" id="myModalIgnore" tabindex="-1" role="dialog" aria-labelledby="myModalIgnore">
	  <div class="modal-dialog" role="document" style="width: 300px;">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title" id="myModalLabel">提示</h4>
	      </div>
	      <div class="modal-body" style="font-size: 18px;text-align: center">
	        是否忽略？
	      </div>
	      <div class="modal-footer">
	        <button type="button" class="btn btn-default doctorNo" data-dismiss="modal">取消</button>
	        <button type="button" class="btn btn-primary doctorIgnoreSure" data-dismiss="modal">确定</button>
	      </div>
	    </div>
	  </div>
	</div>
	
</div>



<div th:replace="inc/footer"></div>
<div th:replace="inc/footer1"></div>

<script th:inline="javascript">
$(function () {
	//格式化日历
    $(".ui_timepicker").datetimepicker({
        showSecond: true,
        timeFormat: 'hh:mm:ss',
        stepHour: 1,
        stepMinute: 1,
        stepSecond: 1
    });
	var doctortype1 = '&type=0';
	var doctorisDisease1 = '';
	var doctordone1 = '';
	function nowDate(){
		var myDate = new Date();
		var y = myDate.getFullYear();    //获取完整的年份(4位,1970-????)
		var m = myDate.getMonth()+1;       //获取当前月份(0-11,0代表1月)
		m = m>9?m:"0"+m;
		var d = myDate.getDate();        //获取当前日(1-31)
		d = d>9?d:"0"+d;
		var date = y+"-"+m+"-"+d+" 00:00:00";
		console.log(date)
		return date;
	}
	function nowTime(){
		var myDate = new Date();
		var y = myDate.getFullYear();    //获取完整的年份(4位,1970-????)
		var m = myDate.getMonth()+1;       //获取当前月份(0-11,0代表1月)
		m = m>9?m:"0"+m;
		var d = myDate.getDate();        //获取当前日(1-31)
		d = d>9?d:"0"+d;
		var h = myDate.getHours();       //获取当前小时数(0-23)
		h = h>9?h:"0"+h;
		var ms = myDate.getMinutes();     //获取当前分钟数(0-59)
		ms = ms>9?ms:"0"+ms;
		var s = myDate.getSeconds();     //获取当前秒数(0-59)
		s = s>9?s:"0"+s;
		var time = y+"-"+m+"-"+d+" "+h+":"+ms+":"+s;
		return time;
	}
	$(".doctor-start-time").val(nowDate());
	$(".doctor-end-time").val(nowTime());

    //点击是否完成
    $(".isDone").on("click",".done-list",function (){
    	var doctorDone = $(this).find("a").text();
    	if($(this).attr("done")){
    		doctordone1 = "&done="+$(this).attr("done");
    	}else{
    		doctordone1 = "";
    	}
    	
    	$(".isDone .done-text").text(doctorDone);
    })

    //点击搜索
    $("#doctorSearch").on("click",function (){
      doctorSearchFn();
    });
    doctorSearchFn();
    function doctorSearchFn(){
      
    	var name = $(".doctor-name").val();
    	var jsbh = $(".doctor-jsbh").text();
    	var startTime = $(".doctor-start-time").val();
    	var endTime = $(".doctor-end-time").val();

    	name = name?"&name="+name:"";
    	startTime = startTime?"&startTime="+startTime:"";
    	endTime = endTime?"&endTime="+endTime:"";
		$.ajax({
			url:"/m/search?jsbh="+jsbh+name+startTime+endTime+doctortype1+doctorisDisease1+doctordone1,
			success:function (result){
				$(".doctorsearch tbody").html("");
				for(var i=0;i<result.length;i++){
					var name = result[i].prisonerName;
					var rybh = result[i].rybh;
					var type = result[i].type;
					if(type==0){
				    	type='医生';
				    }else if(type==1){
				    	type='管教';
				    }else if(type==2){
				    	type='所领导';
				    }else if(type==3){
				    	type='律师';
				    }else if(type==4){
				    	type='检察官';
				    }
					var diseaseName = "";
					if(result[i].diseaseName){
						diseaseName = " ( "+result[i].diseaseName+" )"
					}else{
						diseaseName = "";
					}
					var disease = result[i].disease+diseaseName;
					var done = result[i].done;
					var startTime = result[i].date;
					var endTime = result[i].createTime;
					var status = result[i].status;
          if(startTime){
					startTime = changeTime(startTime);
          }else{
            startTime = '';
          }
          if(endTime){
					endTime = changeTime(endTime);
          }else{
            endTime = '';
          }
					if(done=="1"){
						done = "已完成";
					}else if(done=="0"){
						done = "未完成";
					}
					var statusStr = "";
					if(status=="1"){
						var doctorhandle = "none";
						statusStr = "已处理";
					}else if(status=="2"){
						var doctorhandle = "none";
						statusStr = "已忽略";
					}else{
						var doctorhandle = "inline-block";
						statusStr = "未处理";
					}
					//<td class='done'>"+done+"</td>
					$(".doctorsearch tbody").append("<tr><td>"+name+"</td><td class='rybh'>"+rybh+"</td><td>"+type+"</td><td>"+disease+"</td><td class='statusStr'>"+statusStr+"</td><td class='startTime'>"+startTime+"</td><td>"+endTime+"</td><td class='doctorhandle'><a style='display:"+doctorhandle+"' class='btn btn-xs btn-primary doctorHandle doctorHandlePublic' data-id='true' data-toggle='modal' data-target='#myModal'>处理</a><a style='display:"+doctorhandle+"' class='btn btn-xs btn-primary doctorIgnore doctorHandlePublic' data-id='true' data-toggle='modal' data-target='#myModalIgnore'>忽略</a></td></tr>");
					
				}
				
			}
		})

    	
    	return false;
    }

	//处理
	var doctorHandlerybh = "";
	var doctorHandlestartTime = "";
	var doctorHandlePublic;
	$(".doctorSure").on("click",function (){
		$.ajax({
			url:"/D/dispose?rybh="+doctorHandlerybh+"&startTime="+doctorHandlestartTime+"&status=1",
			success:function (result){
				doctorHandlePublic.hide();
				doctorHandlePublic.siblings().hide();
				doctorHandleDone.text("1");
			}
		})
	});

	$(".doctorsearch").on("click",".doctorHandlePublic",function (){
		doctorHandlerybh = $(this).parent().siblings(".rybh").text();
		doctorHandlestartTime = $(this).parent().siblings(".startTime").text();
		doctorHandleDone = $(this).parent().siblings(".statusStr");
		doctorHandlePublic = $(this);
	});
	
	$(".doctorIgnoreSure").on("click",function (){
		console.log("/D/dispose?rybh="+doctorHandlerybh+"&startTime="+doctorHandlestartTime+"&done=false");
		$.ajax({
			url:"/D/dispose?rybh="+doctorHandlerybh+"&startTime="+doctorHandlestartTime+"&status=2",
			success:function (result){
				if(result.status==200){
					doctorHandlePublic.hide();
					doctorHandlePublic.siblings().hide();
					doctorHandleDone.text("2");
				}
			}
		})
	});
	
	function changeTime(time){
		var d = new Date(time);
		var mm = (d.getMonth() + 1)>9?(d.getMonth() + 1):"0"+(d.getMonth() + 1);
		var dd = (d.getDate())>9?(d.getDate()):"0"+(d.getDate());
		var hh = (d.getHours())>9?(d.getHours()):"0"+(d.getHours());
		var ms = (d.getMinutes())>9?(d.getMinutes()):"0"+(d.getMinutes());
		var ss = (d.getSeconds())>9?(d.getSeconds()):"0"+(d.getSeconds());
		var times=d.getFullYear() + '-' + mm + '-' + dd + ' ' + hh + ':' + ms + ':' + ss; 
		return times;
	}

})


</script>
</body>
</html>
